#ifndef COMPILEOPTIONDIALOG_H
#define COMPILEOPTIONDIALOG_H

#include "CompilerSet.h"
#include "DirectoriesWidget.h"
//编译器选项对话框
class CompileOptionDialog : public QDialog
{
    Q_OBJECT
public:
    CompileOptionDialog(QWidget *parent = 0); //构造函数
    QString getCompileMode();
    void loadDataFromCompilerSet(CompilerSet compilerSet);

private:
    QPushButton *gccButton = nullptr;
    QPushButton *gppButton = nullptr;
    QPushButton *makeButton = nullptr;
    QPushButton *gdbButton = nullptr;
    QPushButton *windresButton = nullptr;
    QPushButton *gprofButton = nullptr;

    QPushButton *questionButton = nullptr;

    QLineEdit *gccLineEdit = nullptr;
    QLineEdit *gppLineEdit = nullptr;
    QLineEdit *makeLineEdit = nullptr;
    QLineEdit *gdbLineEdit = nullptr;
    QLineEdit *windresLineEdit = nullptr;
    QLineEdit *gprofLineEdit = nullptr;

    QComboBox *compilerComboBox = nullptr;
    QLabel *modeLabel=nullptr;
    QComboBox *modeComboBox = nullptr;
    QPlainTextEdit *compileArgTextEdit = nullptr;
    QPlainTextEdit *linkArgTextEdit = nullptr;
    QCheckBox *compileArgCheckBox = nullptr;
    QCheckBox *linkArgCheckBox = nullptr;
    QCheckBox *staticLinkCheckBox=nullptr;
    QCheckBox *warningAllCheckBox=nullptr;
    QCheckBox *warningExtraCheckBox=nullptr;

    QPushButton *addNewSetButton = nullptr;
    QPushButton *addSetFromPathButton = nullptr;
    QPushButton *compilerRenameButton = nullptr;
    QPushButton *removeSetButton = nullptr;

    QPushButton *okButton = nullptr; //定义OK按钮
    QPushButton *cancelButton = nullptr; //定义取消按钮

    DirectoriesWidget *directoriesWidget = nullptr;

    int currentIndex=-1;
    int modeIndex=3;

    void fileButtonClicked();
    void okButtonClicked(); //OK按钮点击时的处理函数
    void writeSettings();
    void cancelButtonClicked();//Cancel按钮点击时的处理函数
    void compileArgCheckBoxStateChanged();
    void linkArgCheckBoxStateChanged();
    void compilerRenameButtonClicked();
    void addSetFromPathButtonClicked();
    void removeSetButtonClicked();
    void addNewSetButtonClicked();
    void GetDirNameList(const QString &path, CompilerSet &compilerSet);
    bool findCompilerFromPath(QString path, CompilerSet& compilerSet);
    void compilerComboBoxCurrentIndexChanged(int index);
    bool compilerSetChanged(int index);
    void saveChangesToCompilerSet(int index);
    void loadCompilerSets();
    void questionButtonClicked();
};
#endif
